//==============================================================================
//
// Title:		CC_Barcode.c
// Purpose:		A short description of the implementation.
//
// Created on:	2022/10/20 at 16:15:20 by .
// Copyright:	. All Rights Reserved.
//
//==============================================================================

//==============================================================================
// Include files

#include <ansi_c.h>

#include "CC_Barcode.h"

//==============================================================================
// Constants

//==============================================================================
// Types

//==============================================================================
// Static global variables

//==============================================================================
// Static functions

//==============================================================================
// Global variables

//==============================================================================
// Global functions

int CC_Barcode_Init(CC_RS232_INFO *Interface, int Port, 
		char PortName[], int BaudRate, int Parity, int DataBits, int StopBits, 
		int InputBufferLength, int OutputBufferLength, double TimeOut, 
		double DelayBetweenCommands, double DelayRead,char WriteEnd[], char ReadEnd)
{
	Interface->port = Port;
	strcpy(Interface->portname, PortName);
	Interface->baud_rate = BaudRate;
	Interface->parity = Parity;
	Interface->data_bits = DataBits;
	Interface->stop_bits = StopBits;
	Interface->inputQueueSize = InputBufferLength;
	Interface->outputQueueSize = OutputBufferLength;
	Interface->time_out = TimeOut;
	Interface->delay_commands = DelayBetweenCommands;
	Interface->delay_read = DelayRead;
	strcpy(Interface->command_end, WriteEnd);
	Interface->read_end = ReadEnd;
	
	int iStatus;
	
	iStatus = CC_RS232_Open(*Interface);
	
	if (iStatus == 0)
		return CC_BCR_OK;
	else
		return CC_BCR_NG;
}

int CC_Barcode_Read_Without_Wait_Process(CC_RS232_INFO Interface, char *NoReadStr, char *Barcode, int MaxBarcodeLength)
{
	CC_RS232_Read_Without_Wait(Interface, Barcode, MaxBarcodeLength);
	
	return CC_BCR_OK;	
}

int CC_Barcode_Close(CC_RS232_INFO Interface)
{
	int iStatus;
	
	iStatus = CC_RS232_Close(Interface);
	
	if (iStatus == 0)
		return CC_BCR_OK;
	else 
		return CC_BCR_NG;
}
